//
//  HomeTableViewCell.m
//  IconMaster
//
//  Created by mac on 2017/7/25.
//  Copyright © 2017年 yangweiwei. All rights reserved.
//

#import "HomeTableViewCell.h"

@implementation HomeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.imgView0 sendSubviewToBack:self];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)lockBtnAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(clickLockButton:)]) {
        [self.delegate clickLockButton:nil];
    }
}
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"homecell";
    HomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (nil == cell) {
        cell =  [[NSBundle mainBundle] loadNibNamed:@"HomeCell" owner:self options:nil].firstObject;
 
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//        cell.backgroundColor = [UIColor redColor];
    }
    cell.imgView0.layer.cornerRadius = 5.0;
    cell.imgView0.layer.masksToBounds = YES;
    return cell;
    
}
- (void)dealWithHomeData:(HomeModel *)model{
    

    [self.imgView0  sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", BaseURLImage, model.coverPath]]];
    self.downCountLab.text = [NSString stringWithFormat:@"%@",model.downString];
    self.popularityLab.text = [model.timeString substringToIndex:10];
    
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"IsLocked"]) {
        if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"IsLocked"] isEqualToString:@"IsLocked"]) {
            if (model.IsLocked) {
                [self.lockBtn setHidden:NO];
                
            }else{
                
                [self.lockBtn setHidden:YES];
            }  
        } else {
            [self.lockBtn setHidden:YES];
        }
        
    }else{
        if (model.IsLocked) {
            [self.lockBtn setHidden:NO];
            
        }else{
            
            [self.lockBtn setHidden:YES];
        }  
    }
}
@end
